<template>
  <div>
    <el-carousel indicator-position="none" arrow="never" height="165px">
      <el-carousel-item v-for="item in picList" :key="item.id">
        <a :href="item.link_url">
          <el-image :src="item.image" fit="fill">
            <!--加载中-->
            <div slot="placeholder" class="cloudN-content-text-pic-status">
              <i class="el-icon-loading status-icon" style="font-size: 30px"></i>
            </div>
            <!--加载失败-->
            <div slot="error" class="cloudN-content-text-pic-status">
              <i class="el-icon-picture-outline status-icon"></i>
            </div>
          </el-image>
        </a>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  data () {
    return {
      picList: [],
      srcList: []
    }
  },
  created () {
    this.getPicList()
  },
  // DOM对象加载完成时
  mounted () {},
  methods: {
    async getPicList () {
      // api/v1/ad/head_ad/{#id}
      const { data: res } = await this.$http.get('/article/api/v1/ad/head_ad/3', { responseType: 'json' })
      if (res.code !== 0) {
        console.log('请求失败！')
      } else {
        res.data.forEach((item) => { this.srcList.push(item.image) })
        this.picList = res.data
        // console.log(res.data)
      }
    }
  },
  computed: {
  },
  name: 'carouselAD'
}
</script>

<style lang="less" scoped>
.el-image{
  width: 100%;
  height:100%;
  //img{
  //  object-fit: none !important;
  //}
}
</style>
